<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.crossriver.crgis.database.service.Application_C_of_OLocalServiceUtil"%>
<%@page import="com.crossriver.crgis.database.model.Application_C_of_O"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.liferay.portal.kernel.util.PrettyDateFormat"%>
<%@ include file="/init.jsp"%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<portlet:defineObjects />

<div id="main">
	<h1>ONLINE APPLICATION(S)</h1>
	<div class="content">
		<p>Welcome to our Online Back Office Application Tracker, Here you can view New Applications, Pending Applications and also Completed Applications.</p>
		
	<table width="100%" align="center" id="messages">
		<tr><th colspan="5">Applications <liferay-ui:icon image="favicon" src="${renderRequest.contextPath}/images/app.gif" /><!--<img src="images/mail.jpg" align="baseline">--></th>
		</tr>
		
		<tr>
      <td colspan="5">
      
      <% 
				PortletURL iteratorURLSend = renderResponse.createRenderURL();
				iteratorURLSend.setParameter("jspPage", "/html/bocofo/view.jsp");
			%>

 <%
   
   ThemeDisplay themeDiplay = (ThemeDisplay) request
   .getAttribute(WebKeys.THEME_DISPLAY);
   
   String userId = "" + themeDiplay.getUserId(); 
   
   %>
			<liferay-ui:search-container id="application"   emptyResultsMessage="no-application-messages" delta="10" iteratorURL="<%= iteratorURLSend %>" >
				<liferay-ui:search-container-results>
					<%
					
						List<Application_C_of_O> applications = Application_C_of_OLocalServiceUtil.getApplication_C_of_OAll("");
												//getApplication_C_of_OAll("");
						
							results = ListUtil.subList(applications,
									searchContainer.getStart(),
									searchContainer.getEnd());
		
							total = applications.size();
		
							pageContext.setAttribute("results", results);
							pageContext.setAttribute("total", total);
							
						
					%>
				</liferay-ui:search-container-results>

				<liferay-ui:search-container-row 
					className="com.crossriver.crgis.database.model.Application_C_of_O" keyProperty="applicationId" modelVar="app">
	
					<%
						SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy hh:mm:ss");
						String formattedDate = "";
						if (app != null  && null != app.getApplicationStartDate()){
							formattedDate = sdf.format(app.getApplicationStartDate());
						}
						 
		
					%>
	
					<liferay-ui:search-container-column-text name="Reference Number" property="referenceNo" />
					<liferay-ui:search-container-column-text name="Date of Submission" value="<%= formattedDate %>" />
					<liferay-ui:search-container-column-text name="Applicant's Name" property="userId"  />
					<liferay-ui:search-container-column-text name="Application Type" property="applicationType"  />
					<liferay-ui:search-container-column-text name="Application " property="application"  />
					<liferay-ui:search-container-column-text name="Status" property="status" />
					<liferay-ui:search-container-column-jsp name="Action" path="/html/bocofo/linkpage.jsp"  />
					<%
						long groupId = themeDisplay.getLayout().getGroupId();
						//String name = Message.class.getName();
						//String msgId = String.valueOf(message.getMessageId());
					%>
				</liferay-ui:search-container-row>
				<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
			</liferay-ui:search-container>
      
      </td>
   	</tr>
	</table>
	
	</div>		

</div>



<script>

</script>